package controller.data.createNewDocumentation;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import controller.data.Comment;
import controller.data.EditDocumentationRevision;

public class CreateNewDocumentationRequest {

	private List<EditDocumentationRevision> revisions;

	private List<Comment> comments;

	private List<Long> ratings;

	private String category;

	private List<String> tags;

	private boolean deletedFlag;

	private long defaultRevision;

	private String javaelement;

	public CreateNewDocumentationRequest(EditDocumentationRevision revision, String javaelement,
			String category, List<String> tags) {
		this.revisions = new ArrayList<EditDocumentationRevision>();
		this.revisions.add(revision);
		this.comments = new ArrayList<Comment>();
		this.ratings = new ArrayList<Long>();
		this.category = category;
		this.tags = new ArrayList<String>();
		this.setJavaelement(javaelement);
		setTags(tags);
		this.deletedFlag = false;
		this.defaultRevision = 0;
	}

	public List<EditDocumentationRevision> getRevisions() {
		return revisions;
	}

	public void setRevisions(List<EditDocumentationRevision> revisions) {
		this.revisions = revisions;
	}

	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	public List<Long> getRatings() {
		return ratings;
	}

	public void setRatings(List<Long> ratings) {
		this.ratings = ratings;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public List<String> getTags() {
		return tags;
	}

	public void setTags(List<String> tags) {
		Set<String> tmp = new HashSet<String>();
		for (String s : tags) {
			if (s.compareTo("") != 0) {
				tmp.add(s.toLowerCase());
			}
		}
		this.tags = new ArrayList<String>(tmp);
	}

	public boolean isDeletedFlag() {
		return deletedFlag;
	}

	public void setDeletedFlag(boolean deletedFlag) {
		this.deletedFlag = deletedFlag;
	}

	public long getDefaultRevision() {
		return defaultRevision;
	}

	public void setDefaultRevision(long defaultRevision) {
		this.defaultRevision = defaultRevision;
	}

	public boolean addRevision(EditDocumentationRevision revision) {
		return revisions.add(revision);
	}

	public boolean addComment(Comment comment) {
		return comments.add(comment);
	}

	public boolean addRating(long rating) {
		return ratings.add(rating);
	}

	public void setJavaelement(String javaelement) {
		this.javaelement = javaelement;
	}

	public String getJavaelement() {
		return javaelement;
	}

}